package com.yixun.lbx.service.impl;

import com.yixun.lbx.entity.YxProBeeBreed;
import com.yixun.lbx.mapper.farm.BeeBreedMapper;
import com.yixun.lbx.service.BeeBreedServie;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Service
@Transactional
public class BeeBreedServieImpl implements BeeBreedServie {
    private final BeeBreedMapper beeBreedMapper;

    public BeeBreedServieImpl(BeeBreedMapper beeBreedMapper) {
        this.beeBreedMapper = beeBreedMapper;
    }

    /**
     * @param map todo
     * @return java.lang.Integer
     * @apiNote getCount
     */
    @Override
    public Integer getCount(HashMap<String, Object> map) {
        return beeBreedMapper.getCount(map);
    }

    /**
     * @param map todo
     * @return java.util.List<com.yixun.lbx.entity.YxProBeeBreed>
     * @apiNote getListByPage
     */
    @Override
    public List<YxProBeeBreed> getListByPage(HashMap<String, Object> map) {
        return beeBreedMapper.getListByPage(map);
    }

    /**
     * @param map todo
     * @return int
     * @apiNote addBeeBreed
     */
    @Override
    public int addBeeBreed(HashMap<String, Object> map) {
        map.put("addTime", getDate());
        return beeBreedMapper.insertSelective(map);
    }

    /**
     * @param map todo
     * @return int
     * @apiNote updateBeeBreed
     */
    @Override
    public int updateBeeBreed(HashMap<String, Object> map) {
        map.put("updateTime", getDate());
        return beeBreedMapper.updateByPrimaryKeySelective(map);
    }

    /**
     * @param map todo
     * @return int
     * @apiNote deleteBeeBreed
     */
    @Override
    public int deleteBeeBreed(HashMap<String, Object> map) {
        return beeBreedMapper.deleteByPrimaryKey(map);
    }

    /**
     * @param beeBreed todo
     * @return java.util.List<com.yixun.lbx.entity.YxProBeeBreed>
     * @apiNote getObjByArgs
     */
    @Override
    public List<YxProBeeBreed> getObjByArgs(YxProBeeBreed beeBreed) {
        return beeBreedMapper.getObjByArgs(beeBreed);
    }

    /**
     * @param map todo
     * @return java.util.List<com.yixun.lbx.entity.YxProBeeBreed>
     * @apiNote getSearchListByPage
     */
    @Override
    public List<YxProBeeBreed> getSearchListByPage(HashMap<String, String> map) {
        return beeBreedMapper.getSearchListByPage(map);
    }

    /**
     * @return java.lang.String
     * @apiNote getDate
     */
    private String getDate() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(new Date());
    }
}
